﻿// --------------------------------------------------------------------------------------
// <copyright file="AdministrativeService.cs" company="NGroup">
// Copyright (c) NGroup. All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------
// <history>
//     <change who="Bui Thanh Nam" date="2013.12.07">Create</change>
// </history>
// --------------------------------------------------------------------------------------

namespace NGroup.VTL.Service
{
    using System.Collections.Generic;
    using NGroup.VTL.DAL;
    using NGroup.VTL.DAL.Abstraction;
    using NGroup.VTL.Models;
    using NGroup.VTL.Service.Abstraction;
    using NGroup.VTL.WebCore;
    using NGroup.VTL.Core.Const;

    public class AdministrativeService : IAdministrativeService
    {
        private IAdministrativeDAO _administrativeDAO;
        private IRetrieveContentDAO _retrieveContentDAO;

        public AdministrativeService()
        {
            _administrativeDAO = new AdministrativeDAO();
            _retrieveContentDAO = new RetrieveContentDAO();
        }

        public bool AddNewProduct(ProductModel model)
        {
            return _administrativeDAO.AddNewProduct(model);
        }

        public bool AddNewNews(NewsModel model)
        {
            return _administrativeDAO.AddNewNews(model);
        }

        public ProductModel GetProductDetail(int parentTypeID, int childTypeID, string uniqueString)
        {
            return _administrativeDAO.GetProductDetailForEdit(parentTypeID, childTypeID, uniqueString);
        }

        public NewsModel GetNewsDetail(string uniqueString, LanguageCodes lang)
        {
            return _administrativeDAO.GetNewsDetailForEdit(uniqueString, lang);
        }

        public void UpdateProduct(ProductModel model)
        {
            _administrativeDAO.UpdateProduct(model);
        }

        public void UpdateNews(NewsModel model)
        {
            _administrativeDAO.UpdateNews(model);
        }

        public UserModel GetUserInformation(string username, string password)
        {
            return _administrativeDAO.GetUserInformation(username, password);
        }

        public List<UserModel> GetUserListByPagingInfo(int currentUserRoleId, ref PagingInfoModel pagingInfo)
        {
            return _administrativeDAO.GetUserListByPagingInfo(currentUserRoleId, ref pagingInfo);
        }

        public bool AddNewUser(UserModel user)
        {
            return _administrativeDAO.AddNewUser(user);
        }

        public List<ProductModel> GetProductListByPagingInfo(string filterAuthor, string filterProductSupType, string filterProductType, ref PagingInfoModel pagingInfo)
        {
            return _administrativeDAO.GetProductListByPagingInfo(filterAuthor, filterProductSupType, filterProductType, ref pagingInfo);
        }

        public List<NewsModel> GetNewsListByPagingInfo(string filterAuthor, int filterNewsTypeId, ref PagingInfoModel pagingInfo)
        {
            return _administrativeDAO.GetNewsListByPagingInfo(filterAuthor, filterNewsTypeId, ref pagingInfo);
        }

        public bool CheckUniqueString(int typeID, string uniqueString)
        {
            return _administrativeDAO.CheckUniqueString(typeID, uniqueString);
        }

        public bool DeleteProduct(ProductModel model)
        {
            return _administrativeDAO.DeleteProduct(model);
        }

        public bool DeletePNews(NewsModel model)
        {
            return _administrativeDAO.DeleteNews(model);
        }

        public bool DeleteUser(UserModel model)
        {
            return _administrativeDAO.DeleteUser(model);
        }

        public bool UpdateUser(UserModel model)
        {
            return _administrativeDAO.UpdateUser(model);
        }

        public List<GenericTypeItem> GetAllContentTypesConfigurations()
        {
            return _administrativeDAO.GetAllContentTypesConfigurations();
        }

        public bool DeleteGenericType(GenericTypeItem model)
        {
            return _administrativeDAO.DeleteGenericType(model);
        }

        public bool UpdateGenericType(GenericTypeItem model)
        {
            return _administrativeDAO.UpdateGenericType(model);
        }

        public bool AddNewGenericType(GenericTypeItem model)
        {
            return _administrativeDAO.AddNewGenericType(model);
        }

        public bool CheckUniqueStringGT(int? supTypeID, int? typeID, string uniqueString)
        {
            return _administrativeDAO.CheckUniqueStringGT(supTypeID, typeID, uniqueString);
        }

        public bool DeleteOrder(int orderId)
        {
            return _administrativeDAO.DeleteOrder(orderId);
        }

        public List<OrderModel> GetOrderListByPagingInfo(string filterProductSupType, string filterProductType, ref PagingInfoModel pagingInfo)
        {
            return _administrativeDAO.GetOrderListByPagingInfo(filterProductSupType, filterProductType, ref pagingInfo);
        }

        public int GetPendingOrdersCount()
        {
            return _administrativeDAO.GetPendingOrdersCount();
        }

        public NewsModel GetNewsDetailForEdit(string uniqueString, LanguageCodes lang)
        {
            return _administrativeDAO.GetNewsDetailForEdit(uniqueString, lang);
        }
    }
}
